/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './standard';
import * as API from './types';

/** 分页查询标准 GET /standard */
export function standardGetStandardPageQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.StandardGetStandardPageParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.standardGetStandardPage(queryKey[1] as typeof options);
    },
    queryKey: ['standardGetStandardPage', options],
  });
}

/** 编辑标准 PUT /standard */
export function useStandardEditStandardMutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.standardEditStandard,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 新增标准 POST /standard */
export function useStandardAddStandardMutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.standardAddStandard,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 删除标准 DELETE /standard */
export function useStandardEditStandard2Mutation(options?: {
  onSuccess?: (value?: API.ResponseModelObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.standardEditStandard2,
    onSuccess(data: API.ResponseModelObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 查询国民经济行业分类树 GET /standard/category/cn */
export function standardGetStandardCategoryCnTreeQueryOptions(options: {
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.standardGetStandardCategoryCnTree(
        queryKey[1] as typeof options
      );
    },
    queryKey: ['standardGetStandardCategoryCnTree', options],
  });
}

/** 分页查询标准（h5） GET /standard/h5 */
export function standardGetStandardPageH5QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.StandardGetStandardPageH5Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.standardGetStandardPageH5(queryKey[1] as typeof options);
    },
    queryKey: ['standardGetStandardPageH5', options],
  });
}

/** 查询标准详情（h5） GET /standard/h5/detail */
export function standardGetStandardDetailH5QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.StandardGetStandardDetailH5Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.standardGetStandardDetailH5(queryKey[1] as typeof options);
    },
    queryKey: ['standardGetStandardDetailH5', options],
  });
}

/** 分级标准统计 GET /standard/statistics */
export function standardStatisticsQueryOptions(options: {
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.standardStatistics(queryKey[1] as typeof options);
    },
    queryKey: ['standardStatistics', options],
  });
}
